package com.six.goods.controller;

import com.six.core.entity.Deposit;
import com.six.core.entity.Spec;
import com.six.core.vo.Result;
import com.six.goods.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2023/2/28  10:19
 */

@RestController
@RequestMapping("/goods/spec")
public class SpecController {
    @Autowired
    private SpecService specService;

    /**
     * 规格--分页查询
     * @param currentPage
     * @param pageSize
     * @param spec
     * @return
     */
    @PostMapping("/selespec")
    @ResponseBody
    public Result selespec(@RequestParam(defaultValue = "1")Integer currentPage, @RequestParam(defaultValue = "5")Integer pageSize, @RequestBody Spec spec){
        return specService.seleAllSpec(currentPage,pageSize,spec);
    }

    /**
     * 规格--添加
     * @param spec
     * @return
     */
    @PostMapping("/insertspec")
    @ResponseBody
    public Result insertspec(@RequestBody Spec spec){
        return specService.insertSpec(spec);
    }

    /**
     * 规格--删除
     * @param id
     * @return
     */
    @DeleteMapping("/deletespec")
    @ResponseBody
    public Result deletespec(Integer id){
        return specService.deleteSpec(id);
    }

    /**
     * 规格--修改
     * @param spec
     * @return
     */
    @PutMapping("/updatespec")
    @ResponseBody
    public Result updatespec(@RequestBody Spec spec){
        return specService.updateSpec(spec);
    }

    //所有---下拉框
    @PostMapping ("/selectAllspec")
    public Result selectAllspec(){
        return specService.selectAllSpec();
    }
}
